All files / src/components/debug AuthDebug.tsx

0% Statements 0/15
0% Branches 0/14
0% Functions 0/4
0% Lines 0/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61                                                                                                                         
'use client';
 
import { useAuth } from '@/contexts/AuthContext';
import { useEffect, useState } from 'react';
 
interface StorageData {
  token: string | null;
  userData: string | null;
  refreshToken: string | null;
  expiration: string | null;
  allKeys?: string[];
}
 
export default function AuthDebug() {
  const { user, isAuthenticated, isLoading } = useAuth();
  const [storageData, setStorageData] = useState<StorageData>({
    token: null,
    userData: null,
    refreshToken: null,
    expiration: null,
    allKeys: []});
 
  useEffect(() => {
    const updateStorageData = () => {
      if (typeof window !== 'undefined') {
        setStorageData({
          token: localStorage.getItem('iptv_auth_token'),
          userData: localStorage.getItem('iptv_user_data'),
          refreshToken: localStorage.getItem('iptv_refresh_token'),
          expiration: localStorage.getItem('iptv_token_expiration'),
          allKeys: Object.keys(localStorage)});
      }
    };
 
    updateStorageData();
    
    // Update every second to see changes
    const interval = setInterval(updateStorageData, 1000);
    
    return () => clearInterval(interval);
  }, []);
 
  if (process.env.NODE_ENV !== 'development') {
    return null;
  }
 
  return (
    <div className="fixed bottom-4 right-4 bg-black text-white p-4 rounded-lg text-xs max-w-md z-50">
      <h3 className="font-bold mb-2">Auth Debug</h3>
      <div className="space-y-1">
        <div>Loading: {isLoading ? 'true' : 'false'}</div>
        <div>Authenticated: {isAuthenticated ? 'true' : 'false'}</div>
        <div>User: {user ? JSON.stringify(user, null, 2) : 'null'}</div>
        <div>Token: {storageData.token ? 'exists' : 'null'}</div>
        <div>UserData: {storageData.userData ? 'exists' : 'null'}</div>
        <div>All Keys: {storageData.allKeys?.join(', ')}</div>
      </div>
    </div>
  );
}